package com.itheima.afternoon.demo02;

import java.util.concurrent.atomic.AtomicInteger;

public class AtomicDemo {
    public static void main(String[] args) {
        AtomicInteger atom = new AtomicInteger(10);
        int num1 = atom.getAndIncrement();
        int num2 = atom.get();
        System.out.println(num1);
        System.out.println(num2);
        System.out.println("------------------------");
        int num3 = atom.incrementAndGet();
        int num4 = atom.get();
        System.out.println(num3);
        System.out.println(num4);
        System.out.println("------------------------");
        int num5 = atom.addAndGet(20);
        int num6 = atom.get();
        System.out.println(num5);
        System.out.println(num6);
        System.out.println("------------------------");
        int num7 = atom.getAndAdd(20);
        int num8 = atom.get();
        System.out.println(num7);
        System.out.println(num8);
    }
}
